#pragma once
#include <ctime>

#define INTEGER_LENGTH	16
#define DECIMAL_LENGTH	8
#define LONG_TYPE_SIZE	32

#define CRC16_INIT_VALUE	0xFFFF
#define CRC16_POLY			0x8005

class ParseUtil
{
public:
	ParseUtil(void);
public:
	~ParseUtil(void);
public:
	int floatToBinary(float f, char* displayTxt, int scale);
	int floatToBinary(float f, char* displayTxt, int scale, bool haveDot);
	int intToBinary(int i, char* displayTxt);
	int intToBinary(int i, char* szDisplayTxt, int length);
	int decToBinary(float f, char* displayTxt, int scale);
	int binaryArrayAdd(char* des, char* src, int arraySize);
	int binaryArrayComplement(char* des, char* src, int arraySize);
	int longToBinary(long l, char* szDisplayTxt);
	int boolToBinary(bool b, char* szDisplayTxt);

	int binaryToInt(char* szBinaryString);
	int binaryToInt(char* szBinaryString, bool isSigned);
	long binaryToLong(char* szBinaryString);
	long binaryToLong(char* szBinaryString, int length);
	bool binaryToBool(char* szBoolString);
	float binaryToFloat(char* szFloatString);

	void partitionFrameString(char* szDesText, int start, int end, char* szFrameString);
	void floatToString(double f,const int strLength,const int decimalLength, char* szText);
	void binaryStr8ToBinaryCharData(char* szStr, char &c);
	void binaryCharDataToBinaryStr8(char c, char* szStr);
	void binaryStrToBinaryData(char* szStr, char* szBinaryData, int byteCount);
	void binaryDataToBinaryStr(char* szBinaryData, char* szStr, int byteCount);

	unsigned int CRC16Char(unsigned int crc16,unsigned char character);
	unsigned int CRC16StringToUInt(char* szString, int length);

	void unsignedIntToBinary(unsigned int ui, char* szBinaryString);
	unsigned int binaryToUnsignedInt(char* szBinaryString);
};

